﻿
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Cat.Helper;
namespace PicServer.Konachan
{
    class Konacha_zip
    {
        public void add_zip() {

            get_old_file();
        }

        private void get_old_file()
        {
            DirectoryInfo dir = new DirectoryInfo(Cat.Helper.Static_value.Konach_path);
           
            DirectoryInfo[] dii = dir.GetDirectories();


          
            //获取子文件夹内的文件列表，递归遍历  
            foreach (DirectoryInfo d in dii)
            {
                String Get_filename = d.FullName.Replace(Path.GetDirectoryName(d.FullName), "").Replace("\\", "");
                if (Get_filename != DateTime.Now.ToString("yyyyMMdd")) {
          bool zip_return=          new Zip_Helper().StartProcess(string.Format("\"{2}7z.exe\" u \"{0}\"   \"{1}*\" ",
              Static_value.savepath + "\\" + DateTime.Now.ToString("yyyyMMdd") + @".zip",d.FullName, Static_value.Zip_path));
                    Console.WriteLine("需要压缩");
                    try
                    {if(zip_return)
                        Directory.Delete(d.FullName, true);
                    }
                    catch (Exception ex){
                        Console.WriteLine(ex);
                    }
                }
                  
            }

          
        }
    }
}
